package com.rzico.basics.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.rzico.util.DateUtils;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.ArrayList;
import java.util.List;

/**
 * <pre>
 *   大转盘数据库对象
 * </pre>
 *
 * @author Rzico Boot
 * @version 1.0
 */
@Data
@JsonIgnoreProperties(value = {"handler"})
@JsonInclude(JsonInclude.Include.NON_NULL)
@Table(name = "wx_turntable")
public class Turntable {

    @Id
    @ApiModelProperty(value = "")
    protected Long id;

    @ApiModelProperty(value = "创建日期")
    protected java.util.Date createDate;

    @ApiModelProperty(value = "修改日期")
    protected java.util.Date modifyDate;

    @ApiModelProperty(value = "创建用户ID")
    protected String userId;

    @ApiModelProperty(value = "活动标题")
    protected String subject;

    @ApiModelProperty(value = "活动类型")
    protected String type;

    @ApiModelProperty(value = "开始时间")
    protected java.util.Date startTime;

    @ApiModelProperty(value = "结束时间")
    protected java.util.Date endTime;

    @ApiModelProperty(value = "活动介绍")
    protected String intro;

    @ApiModelProperty(value = "重复操作回复")
    protected String redoIntro;

    @ApiModelProperty(value = "活动结束主题")
    protected String endSubject;

    @ApiModelProperty(value = "活动结束介绍")
    protected String endIntro;

    @ApiModelProperty(value = "最大参与次数")
    protected Integer attendMax;

    @ApiModelProperty(value = "剩余参与次数")
    protected Integer attendRemain;

    @ApiModelProperty(value = "活动参与频率")
    protected String fqcy;

    @ApiModelProperty(value = "每人参与次数（在频率范围内）")
    protected Integer perAttendMax;

    @ApiModelProperty(value = "记录状态")
    protected String status;

    @ApiModelProperty(value = "参与次数")
    @Transient
    protected Integer attendNum;

    @JsonIgnore
    @ApiModelProperty(value = "是否删除", hidden = true)
    protected Boolean deleted;

    @ApiModelProperty(value = "大转盘奖品集合")
    List<TurntablePrize> prizeList = new ArrayList<>();

    // 获取 拼接的时间
    public String getTurntableDate() {
        if (getStartTime() != null && getEndTime() != null) {
            return DateUtils.getDateStr(getStartTime(), 2) + "至" + DateUtils.getDateStr(getEndTime(), 2);
        }
        return null;
    }

}
